﻿(function($) {
    widgets[3] =
        {
            widgetTypeId: 3,
            optionText: 'Push Button',
            valueChanged: function(notification) {

            },
            getHtml: function(widget) {
                return "<input type='button' class='whiteButton' id='"
                    + widget.WidgetGuid.replace(/-/g, '')
                    + "' value='" + widget.Label + "'/>";
            },
            widgetReady: function(widget) {
                $('#' + widget.WidgetGuid.replace(/-/g, '')).bind('click', function() {
                    $.ajax({
                        type: "GET",
                        url: "/s/changeValue",
                        data: { widgetGuid: $(this).attr('id'), newValue: true },
                        success: function(data) {
                            if (!data) {
                                $("#errorMessage").text("Error seting value!");
                                $('#errorPane').makeFloaty({
                                    spacing: 20, time: '1s'
                                });
                            }
                        }
                    });
                });
            }
        };
})(jQuery);